import re
import cookielib
import urllib
import urllib2

#store the cookies and create an opener that will hold them

cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))

# Install our opener (note that this changes the global opener to the one
# we just made, but you can also just call opener.open() if you want)
urllib2.install_opener(opener)

# The action/ target from the form
authentication_url = 'http://www.douban.com/accounts/login'

# Input parameters we are going to send
payload = {
	'source':"simple",
	'form_email':"your user name",
	'form_password':"your password"
}

data = urllib.urlencode(payload)

req = urllib2.Request(authentication_url,data)

resp = urllib2.urlopen(req)
contents = resp.read()

print contents
